﻿using FreeSql.DataAnnotations;
using System;

namespace GetMan.Core.DB.Entities
{
    [Table(Name = "tb_requests")]
    [Index("request_index_01", nameof(NodeId), IsUnique = true)]
    public class RequestEntity : SortEntity
    {
        public long NodeId
        {
            get; set;
        }

        [Navigate(nameof(NodeId))]
        public NodesEntity Node
        {
            get; set;
        }


        /// <summary>
        /// 请求地址
        /// </summary>
        [Column(StringLength = 1000)]
        public string RequestUrl
        {
            get; set;
        }

        /// <summary>
        /// 请求方式
        /// </summary>
        [Column(StringLength = 20)]
        public string RequestMethod
        {
            get; set;
        }

        /// <summary>
        /// Url请求参数
        /// </summary>
        [Column(StringLength = -1)]
        public string RequestParams
        {
            get; set;
        }

        /// <summary>
        /// FormData参数
        /// </summary>
        [Column(StringLength = -1)]
        public string RequestFormData
        {
            get; set;
        }

        /// <summary>
        /// x-www-form-urlencoded
        /// </summary>
        [Column(StringLength = -1)]
        public string RequestFormUrlEncodeData
        {
            get; set;
        }

        /// <summary>
        /// 请求Body
        /// </summary>
        [Column(StringLength = -1)]
        public string RequestBody
        {
            get; set;
        }

        /// <summary>
        /// Body请求参数类型
        /// </summary>
        public BodyTypeEnum RequestMode
        {
            get; set;
        }

        /// <summary>
        /// 请求头参数内容
        /// </summary>
        [Column(StringLength = -1)]
        public string RequestHeader
        {
            get; set;
        }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime
        {
            get; set;
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime
        {
            get; set;
        }

        /// <summary>
        /// 入参模式
        /// </summary>
        public RequestDataMode DataMode
        {
            get; set;
        }
    }

    public enum RequestDataMode
    {
        none,
        formData,
        formUrlEncode,
        raw
    }

    public enum BodyTypeEnum
    {
        json,
        xml
    }
}